*********************************
* 5 IMBALANCE IN QOG COVARIATES *
*********************************

****************************************
* CONTENT:	(1) Univariates imbalance  *
*			(2) Multivariate imbalance *
****************************************

set more off

* (1) Imbalance in means
************************

* Loading QOG dataset

use WPO_QOG_WVS.dta, clear

* Selecting one year random between 1994 and 2020

drop if year<1994
drop if year>2000

gen random=runiform()

sort country random
bysort country: gen id=_n
keep if id==1

* Fixing inclusion variables

replace E114_inclusion_country=0 if E114_inclusion_country==.
replace E117_inclusion_country=0 if E117_inclusion_country==.
replace D059_inclusion_country=0 if D059_inclusion_country==.

* Taking the log of key variables

gen wdi_pop_log=log(wdi_pop)
gen gdp_log=log(wdi_gdpcappppcur)

* Univariate imblanace in support for strong leader

drop if year>2020
drop if year<1994

ttest wdi_pop_log, by(E114_inclusion_country)
ttest wdi_popf, by(E114_inclusion_country)
ttest wdi_pop14, by(E114_inclusion_country) 
ttest wdi_pop65, by(E114_inclusion_country)
ttest vdem_libdem, by(E114_inclusion_country)
ttest vdem_corr, by(E114_inclusion_country)
ttest gdp_log, by(E114_inclusion_country)
ttest wdi_tele, by(E114_inclusion_country)
ttest lp_lat_abst, by(E114_inclusion_country)
ttest wdi_popurb, by(E114_inclusion_country)
ttest lp_catho80, by(E114_inclusion_country)
ttest lp_muslim80, by(E114_inclusion_country)
ttest lp_protmg80, by(E114_inclusion_country)

* Univariate imblanace in support for democracy

ttest wdi_pop_log, by(E117_inclusion_country)
ttest wdi_popf, by(E117_inclusion_country)
ttest wdi_pop14, by(E117_inclusion_country) 
ttest wdi_pop65, by(E117_inclusion_country)
ttest vdem_libdem, by(E117_inclusion_country)
ttest vdem_corr, by(E117_inclusion_country)
ttest gdp_log, by(E117_inclusion_country)
ttest wdi_tele, by(E117_inclusion_country)
ttest lp_lat_abst, by(E117_inclusion_country)
ttest wdi_popurb, by(E117_inclusion_country)
ttest lp_catho80, by(E117_inclusion_country)
ttest lp_muslim80, by(E117_inclusion_country)
ttest lp_protmg80, by(E117_inclusion_country)

* Univariate imblanace in support for male leader

ttest wdi_pop_log, by(D059_inclusion_country)
ttest wdi_popf, by(D059_inclusion_country)
ttest wdi_pop14, by(D059_inclusion_country) 
ttest wdi_pop65, by(D059_inclusion_country)
ttest vdem_libdem, by(D059_inclusion_country)
ttest vdem_corr, by(D059_inclusion_country)
ttest gdp_log, by(D059_inclusion_country)
ttest wdi_tele, by(D059_inclusion_country)
ttest lp_lat_abst, by(D059_inclusion_country)
ttest wdi_popurb, by(D059_inclusion_country)
ttest lp_catho80, by(D059_inclusion_country)
ttest lp_muslim80, by(D059_inclusion_country)
ttest lp_protmg80, by(D059_inclusion_country)

* (2) Multivariate imbalance
****************************

* Support for strong leader

reg E114_inclusion_country wdi_pop_log wdi_popf wdi_pop14 wdi_pop65 vdem_libdem vdem_corr gdp_log wdi_tele lp_lat_abst wdi_popurb lp_catho80 lp_muslim80 lp_protmg80
outreg2 using table2.doc, p dec(2) replace

* Support for democracy

reg E117_inclusion_country wdi_pop_log wdi_popf wdi_pop14 wdi_pop65 vdem_libdem vdem_corr gdp_log wdi_tele lp_lat_abst wdi_popurb lp_catho80 lp_muslim80 lp_protmg80
outreg2 using table2.doc, p dec(2) append

* Support for male leader

reg D059_inclusion_country wdi_pop_log wdi_popf wdi_pop14 wdi_pop65 vdem_libdem vdem_corr gdp_log wdi_tele lp_lat_abst wdi_popurb lp_catho80 lp_muslim80 lp_protmg80
outreg2 using table2.doc, p dec(2) append



